$(document).ready(function () {
    var lastHash = window.location.hash;

    // CHANGE IN PRODUCTION
    /*$.ajaxSetup({
        cache: true
    });*/
    // Custom navigation
    manualLocationRedirection = false;
    /* autoexecute callbacks */
    $(window).bind('hashchange', function(e) {
        if(window.location.hash.length < 1 && lastHash.length) {
            location.reload();
        }
        ajax_navigation();
        manualLocationRedirection = true;
        if(!lastHash.length) {
            adminbar_enable_ajaxmode();
        }
        return false;
    });
    if(manualLocationRedirection == false) {
        ajax_navigation();
    }
    // If we are not in AJAX, just load application and fade
    if(window.location.hash.indexOf('#!') == -1 || window.location.hash.length < 4) {
        ui_boot_dynamic();
        load_application();
        $('.erra-region').fadeIn();
        adminbar_disable_ajaxmode();
    // If we are in ajax, enable the mode
    } else {
        adminbar_enable_ajaxmode();
    }
});
